/*
 * Copyright (c) 2015, the DeltaSync# project. All Rights Reserved.
 * This project is a C# port of the JDeltaSync project:
 *     http://jdeltasync.googlecode.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using System.Collections.Generic;
using System.Text;

/**
 *
 */
public class SyncRequest {
    private List<Collection> collections;
    
    public SyncRequest(params Collection[] collections)
        : this(new List<Collection>(collections))
    {}
    
    public SyncRequest(List<Collection> collections) {
        this.collections = collections;
    }

    public List<Collection> Collections {
        get { return collections; }
    }
    
    public override string ToString() {
        StringBuilder sb = new StringBuilder(base.ToString() + "(");
        sb.Append("collections").Append("=").Append(collections);
        sb.Append(")");
        return sb.ToString();
    }
    
    public class Collection {
        private string syncKey;
        private string collectionId;
        private Clazz  clazz;
        private List<Command> commands;
        private bool   getChanges;
        private int    windowSize;
        
        public Collection(string syncKey, Clazz clazz, bool getChanges) {
            this.syncKey = syncKey;
            this.clazz   = clazz;
            this.collectionId = null;
            this.commands   = new List<Command>();
            this.getChanges = getChanges;
            this.windowSize = -1;
        }
        
        public Collection(string syncKey, Clazz clazz, string collectionId, 
                bool getChanges, int windowSize) {
            this.syncKey = syncKey;
            this.clazz   = clazz;
            this.collectionId = collectionId;
            this.commands   = new List<Command>();
            this.getChanges = getChanges;
            this.windowSize = windowSize;
        }

        public Collection(string syncKey, Clazz clazz, string collectionId, 
                List<Command> commands) {
            this.syncKey = syncKey;
            this.clazz   = clazz;
            this.collectionId = collectionId;
            this.commands   = commands;
            this.getChanges = false;
            this.windowSize = -1;
        }
        
        public Collection(string syncKey, Clazz clazz, string collectionId, 
                List<Command> commands, bool getChanges, int windowSize) {
            this.syncKey = syncKey;
            this.clazz = clazz;
            this.collectionId = collectionId;
            this.commands = commands;
            this.getChanges = getChanges;
            this.windowSize = windowSize;
        }
        
        public string SyncKey {
            get { return syncKey; }
        }

        public Clazz Clazz {
            get { return clazz; }
        }

        public string CollectionId {
            get { return collectionId; }
        }

        public List<Command> Commands {
            get { return commands; }
        }

        public bool IsGetChanges {
            get { return getChanges; }
        }
        
        public int WindowSize {
            get { return windowSize; }
        }
    }
}
